package com.qezhhnjy.mall.coupon.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qezhhnjy.mall.common.entity.coupon.CategoryBounds;
import com.qezhhnjy.mall.common.http.BaseResult;
import com.qezhhnjy.mall.coupon.service.CategoryBoundsService;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 商品分类积分设置 前端控制器
 * </p>
 *
 * @author qezhhnjy
 * @since 2021-06-27
 */
@RestController
@Api(tags = "商品分类积分设置接口")
@Slf4j
@RequestMapping("/category-bounds")
public class CategoryBoundsController {
    @Resource
    private CategoryBoundsService categoryBoundsService;

    @GetMapping("/get")
    @Operation(summary = "根据id获取商品分类积分设置信息")
    public BaseResult<CategoryBounds> get(Long id) {
        CategoryBounds categoryBounds = categoryBoundsService.getById(id);
        return BaseResult.success(categoryBounds);
    }

    @PostMapping("/save")
    @Operation(summary = "新增商品分类积分设置信息")
    public BaseResult<CategoryBounds> save(@RequestBody CategoryBounds categoryBounds) {
        categoryBoundsService.save(categoryBounds);
        return BaseResult.success(categoryBounds);
    }

    @PutMapping("/update")
    @Operation(summary = "更新商品分类积分设置信息")
    public BaseResult<CategoryBounds> update(@RequestBody CategoryBounds categoryBounds) {
        categoryBoundsService.updateById(categoryBounds);
        return BaseResult.success(categoryBounds);
    }

    @PostMapping("/page")
    @Operation(summary = "分页获取商品分类积分设置信息")
    public BaseResult<Page<CategoryBounds>> page(@RequestBody Page<CategoryBounds> page) {
        categoryBoundsService.page(page);
        return BaseResult.success(page);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "根据id删除商品分类积分设置信息")
    public BaseResult<Long> delete(Long id) {
        categoryBoundsService.removeById(id);
        return BaseResult.success(id);
    }
}

